home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 21.zip / BS1 part 21 / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].7z / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].adf / rexx.lzh / BordersSimpleShapes.pprx < prev    next >
Text File  |  1993-01-29  |  27KB  |  822 lines

  1. /* This Genie puts a decorative border around a box, using data stored in the genie. The resulting border is merged into a single box. The current line and fill colours are used. 
  2. Genie written and © by Don Cox   July 92  */
  3.  
  4.  
  5. address command
  6. signal on error
  7. signal on syntax
  8. signal on halt
  9. signal on break_c
  10. signal on break_d
  11. signal on break_e
  12.  
  13. if ~show("l", "gdarexxsupport.library") then
  14.     if ~addlib("gdarexxsupport.library", 0, -30,0) then
  15.     do
  16.         call ppm_Inform(1,"Please install the gdarexxsupport.library in your libs: directory before running this Genie.")
  17.     end
  18.  
  19. call ppm_AutoUpdate(0)
  20. call SafeEndEdit.rexx()
  21. cr="0a"x
  22.  
  23.  
  24. CurrentUnits = ppm_GetUnits()
  25.  
  26. select
  27.     when CurrentUnits = 1 then do
  28.         units="inches"
  29.         mul = 1
  30.         mul2 = 72
  31.         end
  32.     when CurrentUnits = 2 then do
  33.         units="mm"
  34.         mul = 10
  35.         mul2 = 28.4
  36.         end
  37.     otherwise do 
  38.         call ppm_SetUnits(2)
  39.         units="mm"
  40.         mul = 10
  41.         mul2 = 28.4
  42.         end
  43.     end
  44.  
  45. mainbox = ppm_ClickOnBox("  Click on box to be given a border")
  46. if mainbox = 0 then exit_msg("No box selected")
  47. mainpos = ppm_GetBoxPosition(mainbox)
  48. mainXpos = word(mainpos, 1)
  49. mainYpos = word(mainpos, 2)
  50. mainsize = ppm_GetBoxSize(mainbox)
  51. mainwidth = word(mainsize,1)
  52. mainheight = word(mainsize,2)
  53. mainangle = ppm_GetBoxAngle(mainbox)
  54.  
  55.  
  56. /* Initialize data strings  */
  57. cornerline1 = "" 
  58. cornerline2 = ""
  59. cornerline3 = ""
  60. cornerweight1 = "" 
  61. cornerweight2 = ""
  62. cornerweight3 = ""
  63. sideline1 = ""
  64. sideline2 = ""
  65. sideline3 = ""
  66. cornerXoffset = 0
  67. cornerYoffset = 0
  68. sideXoffset = 0
  69. sideYoffset = 0
  70. cornerfill1 = 0
  71. cornerfill2 = 0
  72. cornerfill3 = 0
  73. sidefill1 = 0
  74. sidefill2 = 0
  75. sidefill3 = 0
  76. lines = 1
  77.  
  78. list = "Greek Key"cr"Two Rules"cr"Two Rules Rounded"cr"Two Rules Reverse Rounded"cr"Three Rules"cr"Battlements"cr"Cutout"cr"Filled Squares"cr"Double Squares"cr"Off-Centre Squares"cr"Filled Triangles"cr"Filled Triangles 2"cr"Three Ls"cr"Bars"
  79. chosen = ppm_SelectFromList("Select Border Pattern",30,14,0,list)
  80. if chosen = "" then exit_msg("Aborted by User")
  81.  
  82. /* Data for various patterns  */
  83.  
  84. select 
  85.  
  86.     when chosen = "Bars" then do
  87.         cornerline1 = "0 0"cr"3 0"cr"3 3"cr"0 3"cr"0 0"
  88.         cornerline2 = "5 0"cr"7 0"cr"7 7"cr"0 7"cr"0 5"cr"5 5"cr"5 0"
  89.         cornerline3 = "9 0"cr"11 0"cr"11 11"cr"0 11"cr"0 9"cr"9 9"cr"9 0"
  90.         sideline1 = "1 0"cr"3 0"cr"3 12"cr"1 12"cr"1 0"
  91.         sideline2 = "5 0"cr"7 0"cr"7 12"cr"5 12"cr"5 0"
  92.         sideheight = 12
  93.         sidewidth = 8
  94.         sideXoffset = 1
  95.         sideYoffset = 0
  96.         cornerheight = 12
  97.         cornerwidth = 12
  98.         cornerXoffset = 0
  99.         cornerYoffset = 0
  100.         cornerfill1 = 1
  101.         cornerfill2 = 1
  102.         cornerfill3 = 1
  103.         sidefill1 = 1
  104.         sidefill2 = 1
  105.         sidefill3 = 0
  106.         lines = 0   /* number of line weights to be set by user  */
  107.         end
  108.  
  109.     when chosen = "Three Ls" then do
  110.         cornerline1 = "0 0"cr"4 0"cr"4 4"cr"0 4"cr"0 0"
  111.         cornerline2 = "6 0"cr"9 0"cr"9 9"cr"0 9"cr"0 6"cr"6 6"cr"6 0"
  112.         sideline1 = "1 0"cr"3 0"cr"3 8"cr"11 8"cr"11 10"cr"1 10"cr"1 0"
  113.         sideline2 = "5 0"cr"7 0"cr"7 4"cr"11 4"cr"11 6"cr"5 6"cr"5 0"
  114.         sideline3 = "9 0"cr"11 0"cr"11 2"cr"9 2"cr"9 0"
  115.         sideheight = 10
  116.         sidewidth = 12
  117.         sideXoffset = 1
  118.         sideYoffset = 0
  119.         cornerheight = 10
  120.         cornerwidth = 10
  121.         cornerXoffset = 0
  122.         cornerYoffset = 0
  123.         cornerfill1 = 1
  124.         cornerfill2 = 1
  125.         sidefill1 = 1
  126.         sidefill2 = 1
  127.         sidefill3 = 1
  128.         lines = 0
  129.         end
  130.  
  131.     when chosen = "Filled Triangles 2" then do
  132.         cornerline1 = "4.3 0"cr"4.3 4.3"cr"0 4.3"cr"4.3 0"
  133.         sideline1 = "0 0"cr"4 0"cr"0 4"cr"0 0"
  134.         sideline2 = "5 1"cr"5 5"cr"1 5"cr"5 1"
  135.         sideheight = 5
  136.         sidewidth = 6.4
  137.         sideXoffset = 0.7
  138.         sideYoffset = 0
  139.         cornerheight = 5
  140.         cornerwidth = 5
  141.         cornerXoffset = 0
  142.         cornerYoffset = 0
  143.         cornerfill1 = 1
  144.         sidefill1 = 1
  145.         sidefill2 = 1
  146.         sidefill3 = 0
  147.         lines = 0
  148.         end
  149.  
  150.     when chosen = "Filled Triangles" then do
  151.         cornerline1 = "2.6 0"cr"2.6 2.6"cr"0 2.6"cr"2.6 0"
  152.         sideline1 = "0 0"cr"4 4"cr"0 4"cr"0 0"
  153.         sideline2 = "2 0"cr"10 0"cr"6 4"cr"2 0"
  154.         sideline3 = "12 0"cr"12 4"cr"8 4"cr"12 0"
  155.         sideheight = 4
  156.         sidewidth = 12
  157.         sideXoffset = 0
  158.         sideYoffset = 0
  159.         cornerheight = 4
  160.         cornerwidth = 4
  161.         cornerXoffset = 0
  162.         cornerYoffset = 0
  163.         cornerfill1 = 1
  164.         sidefill1 = 1
  165.         sidefill2 = 1
  166.         sidefill3 = 1
  167.         lines = 0
  168.         end
  169.  
  170.     when chosen = "Off-Centre Squares" then do
  171.         cornerline1 = "0 0"cr"4 0"cr"4 4"cr"0 4"cr"0 0"
  172.         cornerline2 = "0 0"cr"2 0"cr"2 2"cr"0 2"cr"0 0"
  173.         sideline1 = "1 0"cr"5 0"cr"5 4"cr"1 4"cr"1 0"
  174.         sideline2 = "1 0"cr"3 0"cr"3 2"cr"1 2"cr"1 0"
  175.         sideheight = 5
  176.         sidewidth = 6
  177.         sideXoffset = 1
  178.         sideYoffset = 0
  179.         cornerheight = 5
  180.         cornerwidth = 5
  181.         cornerXoffset = 0
  182.         cornerYoffset = 0
  183.         cornerfill1 = 0
  184.         sidefill1 = 0
  185.         lines = 1
  186.         end
  187.  
  188.     when chosen = "Double Squares" then do
  189.         cornerline1 = "0 0"cr"4 0"cr"4 4"cr"0 4"cr"0 0"
  190.         cornerline2 = "1 1"cr"3 1"cr"3 3"cr"1 3"cr"1 1"
  191.         sideline1 = "1 0"cr"5 0"cr"5 4"cr"1 4"cr"1 0"
  192.         sideline2 = "2 1"cr"4 1"cr"4 3"cr"2 3"cr"2 1"
  193.         sideheight = 5
  194.         sidewidth = 6
  195.         sideXoffset = 1
  196.         sideYoffset = 0
  197.         cornerheight = 5
  198.         cornerwidth = 5
  199.         cornerXoffset = 0
  200.         cornerYoffset = 0
  201.         cornerfill1 = 0
  202.         sidefill1 = 0
  203.         lines = 1
  204.         end
  205.  
  206.     when chosen = "Filled Squares" then do
  207.         cornerline1 = "0 0"cr"4 0"cr"4 4"cr"0 4"cr"0 0"
  208.         sideline1 = "1 0"cr"5 0"cr"5 4"cr"1 4"cr"1 0"
  209.         sideheight = 5
  210.         sidewidth = 6
  211.         sideXoffset = 1
  212.         sideYoffset = 0
  213.         cornerheight = 5
  214.         cornerwidth = 5
  215.         cornerXoffset = 0
  216.         cornerYoffset = 0
  217.         cornerfill1 = 1
  218.         sidefill1 = 1
  219.         lines = 0
  220.         end
  221.  
  222.     when chosen = "Cutout" then do
  223.         cornerline1 = "0 1"cr"0 0"cr"1 0"
  224.         sideline1 = "0 0"cr"1 0"
  225.         sideline2 = "3 0"cr"4 0"
  226.         sideheight = 1
  227.         sidewidth = 4
  228.         sideXoffset = 0
  229.         sideYoffset = 0
  230.         cornerheight = 1
  231.         cornerwidth = 1
  232.         cornerXoffset = 0
  233.         cornerYoffset = 0
  234.         lines = 1
  235.         end
  236.  
  237.     when chosen = "Battlements" then do
  238.         cornerline1 = "0 0"cr"3.3 0"cr"3.3 2.3"cr"2.3 2.3"cr"2.3 3.3"cr"0 3.3"cr"0 0"
  239.         sideline1 = "0 6"cr"1 6"cr"1 0"cr"3 0"cr"3 6"cr"4 6"
  240.         sideheight = 6
  241.         sidewidth = 4
  242.         sideXoffset = 0
  243.         sideYoffset = 0
  244.         cornerheight = 4
  245.         cornerwidth = 4
  246.         cornerXoffset = 0
  247.         cornerYoffset = 0
  248.         lines = 1
  249.         end
  250.  
  251.     when chosen = "Greek Key" then do
  252.         sideline1 = "0 0"cr"6 0"cr"6 5"cr"3 5"cr"3 3"cr"2 3"cr"2 6"cr"7 6"cr"7 0"cr"8 0"
  253.         sideline2 = "0 1"cr"5 1"cr"5 4"cr"4 4"cr"4 2"cr"1 2"cr"1 7"cr"8 7"cr"8 1"
  254.         sideheight = 8
  255.         sidewidth = 8
  256.         sideXoffset = 0
  257.         sideYoffset = 0
  258.         cornerheight = 8
  259.         cornerwidth = 8
  260.         cornerXoffset = 0
  261.         cornerYoffset = 0
  262.         Cornerline1 = "0 8"cr"0 0"cr"6 0"cr"6 5"cr"2 5"cr"2 2"cr"4 2"cr"4 3"cr"3 3"cr"3 4"cr"5 4"cr"5 1"cr"1 1"cr"1 6"cr"7 6"cr"7 0"cr"8 0"
  263.         Cornerline2 = "1 8"cr"1 7"cr"8 7"cr"8 1"
  264.         lines = 0
  265.         end
  266.  
  267.     when chosen = "Two Rules" then do
  268.         sideline1 = ""
  269.         sideline2 = ""
  270.         Cornerline1 = ""
  271.         cornerline2 = ""
  272.         lines = 2
  273.         end
  274.  
  275.     when chosen = "Two Rules Rounded" | chosen = "Two Rules Reverse Rounded" then do
  276.         sideline1 = ""
  277.         sideline2 = ""
  278.         Cornerline1 = ""
  279.         cornerline2 = ""
  280.         lines = 100    /* impossible number as a flag */
  281.         end
  282.  
  283.     when chosen = "Three Rules" then do
  284.         sideline1 = ""
  285.         sideline2 = ""
  286.         Cornerline1 = ""
  287.         cornerline2 = ""
  288.         lines = 3
  289.         end
  290.  
  291.     otherwise do
  292.         cornerline1 = "" 
  293.         cornerline2 = ""
  294.         cornerline3 = ""
  295.         sideline1 = ""
  296.         sideline2 = ""
  297.         sideline3 = ""
  298.         end
  299.     end
  300.  
  301.  
  302. /* Collect line weights from user  */
  303.  
  304. if lines>3  & lines~=100 then lines = 3
  305.  
  306. select
  307.     when lines = 0 then do
  308.         form = ppm_GetForm("Set sizes",8,"Border width ("units")")
  309.         if form = "" then exit_msg("Aborted by user")
  310.         cornerweight1 = ""
  311.         parse var form breadth 
  312.         end
  313.  
  314.     when lines = 1 then do
  315.         form = ppm_GetForm("Set sizes",8,"Border width ("units")"cr"Line weight (points)")
  316.         if form = "" then exit_msg("Aborted by user")
  317.         parse var form breadth "0a"x cornerweight1
  318.         end
  319.  
  320.     when lines = 2 then do
  321.         form = ppm_GetForm("Set sizes",8,"Border width ("units")"cr"Line 1 (points)"cr"Line 2 (points)")
  322.         if form = "" then exit_msg("Aborted by user")
  323.         parse var form breadth "0a"x cornerweight1 "0a"x cornerweight2
  324.         end
  325.  
  326.     when lines = 3 then do
  327.         form = ppm_GetForm("Set sizes",8,"Border width ("units")"cr"Line 1 (points)"cr"Line 2 (points)"cr"Line 3 (points)")
  328.         if form = "" then exit_msg("Aborted by user")
  329.         parse var form  breadth "0a"x cornerweight1 "0a"x cornerweight2 "0a"x cornerweight3
  330.         end
  331.  
  332.     when lines = 100 then do
  333.         form = ppm_GetForm("Set sizes",8,"Border width ("units")"cr"Line 1 (points)"cr"Line 2 (points)"cr"Corner Radius ("units")")
  334.         if form = "" then exit_msg("Aborted by user")
  335.         parse var form  breadth "0a"x cornerweight1 "0a"x cornerweight2 "0a"x cornerRadius
  336.         if cornerRadius = "" then cornerRadius = breadth*2
  337.         end
  338.  
  339.     otherwise nop
  340.     end
  341.  
  342.  
  343. if breadth="" then exit_msg("Aborted by User")
  344. breadth = breadth/mul /* mm to cm */
  345. if breadth>(word(mainsize,1))/2 | breadth>(word(mainsize,2))/2 then exit_msg("Too big")
  346.  
  347. defaultweight = (breadth*mul2)/20
  348. if cornerweight1 = "" then cornerweight1 = defaultweight
  349. if cornerweight2 = "" then cornerweight2 = defaultweight
  350. if cornerweight3 = "" then cornerweight3 = defaultweight
  351.  
  352. if lines = 1 | lines = 0 then do
  353.     cornerweight2 = cornerweight1
  354.     cornerweight3 = cornerweight1
  355.     end
  356. if lines = 2 then cornerweight3 = cornerweight2
  357. sideweight1 = cornerweight1
  358. sideweight2 = cornerweight2
  359. sideweight3 = cornerweight3
  360. maxweight = max(cornerweight1, cornerweight2, cornerweight3)
  361. maxwt = maxweight/72  /* max. line weight in inches  */
  362. if CurrentUnits = 2 then maxwt = maxwt*2.54  /* or centimetres  */
  363.  
  364.  
  365. /* First deal with plain rectangular borders  */
  366.  
  367. if chosen = "Two Rules" then do
  368.         call ppm_SetFillPattern(0)
  369.         call ppm_NewGroup()
  370.         call ppm_SetLineWeight(sideweight1)
  371.         rect1 = ppm_DrawRect(mainXpos, mainYpos, mainXpos+word(mainsize,1), mainYpos+word(mainsize,2))
  372.         call ppm_AddToGroup(rect1)
  373.         call ppm_SetLineWeight(sideweight2)
  374.         rect2 = ppm_DrawRect(mainXpos+breadth, mainYpos+breadth, mainXpos+word(mainsize,1)-breadth, mainYpos+word(mainsize,2)-breadth)
  375.         call ppm_AddToGroup(rect2)
  376.         borderbox = ppm_MergeGroup()
  377.         call ppm_SetBoxAngle(borderbox,mainangle)
  378.         call ppm_SetBoxPosition(borderbox,mainXpos,mainYpos)
  379. /* Set an arbitrary margin in main box  */
  380.         margin = breadth*2
  381.         call ppm_SetBoxMargins(mainbox, margin, margin, margin, margin)
  382.         exit_msg("Done")
  383.         end
  384.  
  385. if chosen = "Two Rules Rounded" | chosen = "Two Rules Reverse Rounded" then do
  386.         rev = 0
  387.         if chosen = "Two Rules Reverse Rounded" then rev = 1
  388.         call ppm_ShowStatus("  Calculating outer line ...")
  389.         call ppm_SetFillPattern(0)
  390.         call ppm_NewGroup()
  391. cornerRadius = cornerRadius/mul /* convert units */
  392. cRadius = cornerRadius /* for positioning centres of arcs */
  393.  
  394. AA=6.2831853/360    /* 2pi divided by 360 */
  395. AAA=AA*3
  396. angle= 180*AA /* convert to radians  */
  397. if rev = 1 then do /* for reverse curve corners  */
  398.     angle = 90*AA
  399.     AAA=-AAA  /* anti-clockwise arcs  */
  400.     cRadius = 0
  401.     end
  402.  
  403. drawstring = mainXpos (mainYpos+cornerRadius)||"0a"x
  404.  
  405. /* Draw the outer line, using 3 degree steps to give a smooth curve */
  406.         call ppm_SetLineWeight(sideweight1)
  407.         Xcentre = mainXpos+cRadius  /* centre of corner arc  */
  408.         Ycentre = mainYpos+cRadius
  409.         do i = 1 to 30
  410.             X2=Xcentre+(cornerRadius*cos(angle))
  411.             Y2=Ycentre+(cornerRadius*sin(angle))
  412.             angle=angle+AAA
  413.             drawstring=drawstring||X2 Y2"0a"x
  414.             end
  415.         if rev = 1 then drawstring = drawstring||(mainXpos +cornerRadius) mainYpos"0a"x
  416.         drawstring = drawstring||(mainXpos +mainwidth -cornerRadius) mainYpos"0a"x
  417.         Xcentre = mainXpos+mainwidth-cRadius
  418.         Ycentre = mainYpos+cRadius
  419.         if rev = 1 then angle = angle+(60*AAA)
  420.         do i = 1 to 30
  421.             X2=Xcentre+(cornerRadius*cos(angle))
  422.             Y2=Ycentre+(cornerRadius*sin(angle))
  423.             angle=angle+AAA
  424.             drawstring=drawstring||X2 Y2"0a"x
  425.             end
  426.         if rev = 1 then drawstring = drawstring||(mainXpos +mainwidth) (mainYpos+cornerRadius)"0a"x
  427.         drawstring = drawstring||(mainXpos+mainwidth) (mainYpos+mainheight-cornerRadius)"0a"x
  428.  
  429.         Xcentre = mainXpos+mainwidth-cRadius
  430.         Ycentre = mainYpos+mainheight-cRadius
  431.         if rev = 1 then angle = angle+(60*AAA)
  432.         do i = 1 to 30
  433.             X2=Xcentre+(cornerRadius*cos(angle))
  434.             Y2=Ycentre+(cornerRadius*sin(angle))
  435.             angle=angle+AAA
  436.             drawstring=drawstring||X2 Y2"0a"x
  437.             end
  438.         if rev = 1 then drawstring = drawstring||(mainXpos +mainwidth -cornerRadius) (mainYpos+mainheight)"0a"x
  439.         drawstring = drawstring||(mainXpos+cornerRadius) (mainYpos+mainheight)"0a"x
  440.         Xcentre = mainXpos+cRadius
  441.         Ycentre = mainYpos+mainheight-cRadius
  442.         if rev = 1 then angle = angle+(60*AAA)
  443.         do i = 1 to 30
  444.             X2=Xcentre+(cornerRadius*cos(angle))
  445.             Y2=Ycentre+(cornerRadius*sin(angle))
  446.             angle=angle+AAA
  447.             drawstring=drawstring||X2 Y2"0a"x
  448.             end
  449.         if rev = 1 then drawstring = drawstring||mainXpos (mainYpos+mainheight-cornerRadius)"0a"x
  450.         drawstring = drawstring||mainXpos (mainYpos+cornerRadius)"0a"x
  451.         call ppm_SaveText("ram:arcdata",drawstring)
  452.         box = ppm_DrawPoly("ram:arcdata",boxname)
  453.         call ppm_AddToGroup(box)
  454.  
  455. /* Draw the inner arc, in 3 degree steps to give a smooth curve */
  456.         call ppm_ShowStatus("  Calculating inner line ...")
  457.         call ppm_SetLineWeight(sideweight2)
  458.         cornerRadius2 = cornerRadius-breadth
  459.         if rev = 1 then do
  460.             cornerRadius2 = cornerRadius+breadth
  461.             cornerRadius = cornerRadius+breadth
  462.             a2 = sin(90*AA)/cornerRadius*breadth
  463.             a2 = atan(a2/sqrt(-a2*a2+1))
  464.             a3 = 3.1415927-(90*AA)-a2
  465.             startangle = a2
  466.             arcangle = (90*AA)-(2*startangle)
  467.             AAA = -(arcangle/30)
  468.             angle = (90*AA)-startangle
  469.             end
  470. /* first corner */
  471.         drawstring = (mainXpos+breadth) (mainYpos+cornerRadius)||"0a"x
  472.         Xcentre = mainXpos+cRadius
  473.         Ycentre = mainYpos+cRadius
  474.         do i = 0 to 30
  475.             X2=Xcentre+(cornerRadius2*cos(angle))
  476.             Y2=Ycentre+(cornerRadius2*sin(angle))
  477.             angle=angle+AAA
  478.             drawstring=drawstring||X2 Y2"0a"x
  479.             end
  480.         if rev = 1 then drawstring = drawstring||(mainXpos +cornerRadius) (mainYpos+breadth)"0a"x
  481.         drawstring = drawstring||(mainXpos +mainwidth -cornerRadius) (mainYpos+breadth)"0a"x
  482.  
  483. /* second corner */
  484.         Xcentre = mainXpos+mainwidth-cRadius
  485.         Ycentre = mainYpos+cRadius
  486.         if rev = 1 then angle = (180*AA)-startangle
  487.         do i = 0 to 30
  488.             X2=Xcentre+(cornerRadius2*cos(angle))
  489.             Y2=Ycentre+(cornerRadius2*sin(angle))
  490.             angle=angle+AAA
  491.             drawstring=drawstring||X2 Y2"0a"x
  492.             end
  493.         if rev = 1 then drawstring = drawstring||(mainXpos +mainwidth -breadth) (mainYpos+cornerRadius)"0a"x
  494.         drawstring = drawstring||(mainXpos+mainwidth-breadth) (mainYpos+mainheight-cornerRadius)"0a"x
  495.  
  496. /* third corner  */
  497.         Xcentre = mainXpos+mainwidth-cRadius
  498.         Ycentre = mainYpos+mainheight-cRadius
  499.         if rev = 1 then angle = (270*AA)-startangle
  500.         do i = 0 to 30
  501.             X2=Xcentre+(cornerRadius2*cos(angle))
  502.             Y2=Ycentre+(cornerRadius2*sin(angle))
  503.             angle=angle+AAA
  504.             drawstring=drawstring||X2 Y2"0a"x
  505.             end
  506.         if rev = 1 then drawstring = drawstring||(mainXpos +mainwidth -cornerRadius) (mainYpos+mainheight-breadth)"0a"x
  507.         drawstring = drawstring||(mainXpos+cornerRadius) (mainYpos+mainheight-breadth)"0a"x
  508.  
  509. /* fourth corner  */
  510.         Xcentre = mainXpos+cRadius
  511.         Ycentre = mainYpos+mainheight-cRadius
  512.         if rev = 1 then angle = 0-startangle
  513.         do i = 0 to 30
  514.             X2=Xcentre+(cornerRadius2*cos(angle))
  515.             Y2=Ycentre+(cornerRadius2*sin(angle))
  516.             angle=angle+AAA
  517.             drawstring=drawstring||X2 Y2"0a"x
  518.             end
  519.         if rev = 1 then drawstring = drawstring||(mainXpos +breadth) (mainYpos+mainheight-cornerRadius)"0a"x
  520.         drawstring = drawstring||(mainXpos+breadth) (mainYpos+cornerRadius)"0a"x
  521.         call ppm_SaveText("ram:arcdata2",drawstring)
  522.         box = ppm_DrawPoly("ram:arcdata2",boxname)
  523.         call ppm_AddToGroup(box)
  524.         borderbox = ppm_MergeGroup()
  525.         call ppm_SetBoxAngle(borderbox,mainangle)
  526.         call ppm_SetBoxPosition(borderbox,mainXpos-((sideweight1/2)/mul2), mainYpos-((sideweight1/2)/mul2))  
  527.  
  528.  
  529. /* Set an arbitrary margin in main box  */
  530.         margin = cornerRadius*1.2
  531.         call ppm_SetBoxMargins(mainbox, margin, margin, margin, margin)
  532.         exit_msg()
  533.         end
  534.  
  535.  
  536. if chosen = "Three Rules" then do
  537.         call ppm_NewGroup()
  538.         call ppm_SetLineWeight(sideweight1)
  539.         call ppm_SetFillPattern(0)
  540.         rect1 = ppm_DrawRect(mainXpos, mainYpos, mainXpos+word(mainsize,1), mainYpos+word(mainsize,2))
  541.         call ppm_AddToGroup(rect1)
  542.         call ppm_SetLineWeight(sideweight2)
  543.         rect2 = ppm_DrawRect(mainXpos+(breadth/3), mainYpos+(breadth/3), mainXpos+word(mainsize,1)-(breadth/3), mainYpos+word(mainsize,2)-(breadth/3))
  544.         call ppm_AddToGroup(rect2)
  545.         call ppm_SetLineWeight(sideweight3)
  546.         rect3 = ppm_DrawRect(mainXpos+breadth, mainYpos+breadth, mainXpos+word(mainsize,1)-breadth, mainYpos+word(mainsize,2)-breadth)
  547.         call ppm_AddToGroup(rect3)
  548.         borderbox = ppm_MergeGroup()
  549.         call ppm_SetBoxAngle(borderbox,mainangle)
  550.         call ppm_SetBoxPosition(borderbox,mainXpos,mainYpos)
  551. /* Set an arbitrary margin in main box  */
  552.         margin = breadth*2
  553.         call ppm_SetBoxMargins(mainbox, margin, margin, margin, margin)
  554.         exit_msg("Done")
  555.         end
  556.  
  557.  
  558. /* Now deal with borders using shapes scaled to fit  */
  559.  
  560. mainheight = (word(mainsize, 2))-(breadth*2)
  561. mainwidth = (word(mainsize, 1))-(breadth*2)
  562.  
  563. call ppm_NewGroup()
  564. count = 0
  565.  
  566. if cornerline1 ~= "" then do
  567.     drawstring = cornerline1
  568.     call ppm_SaveText("ram:linedata",drawstring)
  569.     call ppm_SetLineWeight(cornerweight1)
  570.     call ppm_SetFillPattern(cornerfill1)
  571.     cornerbox = ppm_DrawPoly("ram:linedata")
  572.     call ppm_AddToGroup(cornerbox)
  573.     count = count+1
  574.     end
  575.  
  576. if cornerline2 ~= "" then do
  577.     drawstring = cornerline2
  578.     call ppm_SaveText("ram:linedata",drawstring)
  579.     call ppm_SetLineWeight(cornerweight2)
  580.     call ppm_SetFillPattern(cornerfill2)
  581.     cornerbox = ppm_DrawPoly("ram:linedata")
  582.     call ppm_AddToGroup(cornerbox)
  583.     count = count+1
  584.     end
  585.  
  586. if cornerline3 ~= "" then do
  587.     drawstring = cornerline3
  588.     call ppm_SaveText("ram:linedata",drawstring)
  589.     call ppm_SetLineWeight(cornerweight3)
  590.     call ppm_SetFillPattern(cornerfill3)
  591.     cornerbox = ppm_DrawPoly("ram:linedata")
  592.     call ppm_AddToGroup(cornerbox)
  593.     count = count+1
  594.     end
  595.  
  596. if count>1 then cornerbox = ppm_MergeGroup() /* Merge fails with 1 box */
  597.  
  598. if cornerbox ~=0 then do
  599.     if cornerheight~=0 & cornerwidth~=0 then call ppm_SetBoxSize(cornerbox, cornerwidth, cornerheight)
  600.     call ppm_SetBoxOffset(cornerbox,cornerXoffset,cornerYoffset)
  601.     csize = ppm_GetBoxSize(cornerbox)
  602.     cXsize = word(csize, 1)
  603.     cYsize = word(csize, 2)
  604.     cscale = ppm_GetBoxScale(cornerbox)
  605.     cscaleX = word(cscale, 1)
  606.     cscaleY = word(cscale, 2)
  607.     cangle = ppm_GetBoxAngle(cornerbox)
  608.     end
  609.  
  610.  
  611. call ppm_NewGroup()
  612. count = 0
  613.  
  614. if sideline1 ~= "" then do
  615.     drawstring = sideline1
  616.     call ppm_SaveText("ram:linedata",drawstring)
  617.     call ppm_SetLineWeight(sideweight1)
  618.     call ppm_SetFillPattern(sidefill1)
  619.     sidebox = ppm_DrawPoly("ram:linedata")
  620.     call ppm_AddToGroup(sidebox)
  621.     count = count+1
  622.     end
  623.  
  624. if sideline2 ~= "" then do
  625.     drawstring = sideline2
  626.     call ppm_SaveText("ram:linedata",drawstring)
  627.     call ppm_SetLineWeight(sideweight2)
  628.     call ppm_SetFillPattern(sidefill2)
  629.     sidebox = ppm_DrawPoly("ram:linedata")
  630.     call ppm_AddToGroup(sidebox)
  631.     count = count+1
  632.     end
  633.  
  634. if sideline3 ~= "" then do
  635.     drawstring = sideline3
  636.     call ppm_SaveText("ram:linedata",drawstring)
  637.     call ppm_SetLineWeight(sideweight3)
  638.     call ppm_SetFillPattern(sidefill3)
  639.     sidebox = ppm_DrawPoly("ram:linedata")
  640.     call ppm_AddToGroup(sidebox)
  641.     count = count+1
  642.     end
  643.  
  644. if count>1 then sidebox = ppm_MergeGroup()
  645.  
  646.  
  647. /* Place Corner Units */
  648. call ppm_NewGroup()
  649. call ppm_ShowStatus("Placing Corner Units")
  650. if cornerbox ~=0 then do
  651.     cbox = ppm_CloneBox(cornerbox, 0, 0)
  652.     call ppm_AddToGroup(cbox)
  653.     call ppm_SetBoxAngle(cbox,0)
  654.     call ppm_SetBoxSize(cbox, breadth, breadth)
  655.     call ppm_SetBoxScale(cbox, cscaleX*breadth/cXsize, cscaleY*breadth/cYsize)
  656.     call ppm_SetBoxPosition(cbox, mainXpos, mainYpos)
  657.     cbox2 = ppm_CloneBox(cbox, 0, 0)
  658.     call ppm_AddToGroup(cbox2)
  659.     call ppm_SetBoxPosition(cbox2, mainXpos, mainYpos+mainheight+breadth)
  660.     call ppm_SetBoxAngle(cbox2, (cangle+90)//360)
  661.     cbox3 = ppm_CloneBox(cbox, 0, 0)
  662.     call ppm_AddToGroup(cbox3)
  663.     call ppm_SetBoxPosition(cbox3, mainXpos+mainwidth+breadth, mainYpos+mainheight+breadth)
  664.     call ppm_SetBoxAngle(cbox3, (cangle+180)//360)
  665.     cbox4 = ppm_CloneBox(cbox, 0, 0)
  666.     call ppm_AddToGroup(cbox4)
  667.     call ppm_SetBoxPosition(cbox4, mainXpos+mainwidth+breadth, mainYpos)
  668.     call ppm_SetBoxAngle(cbox4, (cangle+270)//360)
  669.     call ppm_SetBoxAngle(cbox, cangle)
  670.     end
  671.  
  672.  
  673. if sidebox = 0 then exit_msg("Done")
  674.  
  675.  
  676. /* Collect original size and graphic scale of box */
  677.     if sideheight~=0 & sidewidth~=0 then call ppm_SetBoxSize(sidebox, sidewidth, sideheight)
  678.     call ppm_SetBoxOffset(sidebox,sideXoffset,sideYoffset)
  679.     scaleX = word(ppm_GetBoxScale(sidebox), 1)
  680.     scaleY = word(ppm_GetBoxScale(sidebox), 2)
  681.     width = word(ppm_GetBoxSize(sidebox), 1)
  682.     height = word(ppm_GetBoxSize(sidebox), 2)
  683.     scale1 = breadth/height
  684.     width2 = width*scale1
  685. totalwidth = width2
  686.  
  687.  
  688. heightcount = mainheight%totalwidth /* Use integer division to get number of repeats */
  689. widthcount = mainwidth%totalwidth
  690. if widthcount = 0 | heightcount = 0 then do
  691.     gone = ppm_DeleteBox(sidebox)
  692.     gone = ppm_DeleteBox(cornerbox)
  693.     gone = ppm_DeleteBox(cbox)
  694.     gone = ppm_DeleteBox(cbox2)
  695.     gone = ppm_DeleteBox(cbox3)
  696.     gone = ppm_DeleteBox(cbox4)
  697.     exit_msg("Pattern too big")
  698.     end
  699.  
  700. Xtotalwidth = mainwidth/widthcount  /* Exact width of whole pattern */
  701. Ytotalwidth = mainheight/heightcount
  702. Xscale = Xtotalwidth/totalwidth
  703. Yscale = Ytotalwidth/totalwidth
  704.  
  705.  
  706. widthX = width2*Xscale
  707. widthY = width2*Yscale 
  708.  
  709.  
  710. /* Place top units  */
  711.  
  712. call ppm_ShowStatus("Placing Top Units")
  713. leftpos = mainXpos+breadth
  714. do j=1 to widthcount
  715.     newbox = ppm_CloneBox(sidebox, 0, 0)
  716.     call ppm_AddToGroup(newbox)
  717.     call ppm_SetBoxSize(newbox, widthX, breadth)
  718.     call ppm_SetBoxPosition(newbox, leftpos, mainYpos)
  719.     call ppm_SetBoxScale(newbox, (scaleX *scale1* Xscale), (scaleY * abs(scale1)) )
  720.     call ppm_SetBoxAngle(newbox, 0)
  721.     leftpos = leftpos+widthX
  722.     end
  723.  
  724. /* Place right side units */
  725. call ppm_ShowStatus("Placing Right Side Units")
  726. toppos = mainYpos+breadth
  727. leftpos = mainXpos+word(mainsize, 1)
  728.  
  729. do j=1 to heightcount
  730.     newbox = ppm_CloneBox(sidebox, 0, 0)
  731.     call ppm_AddToGroup(newbox)
  732.     call ppm_SetBoxAngle(newbox, 270)
  733.     call ppm_SetBoxSize(newbox, widthY, breadth)
  734.     call ppm_SetBoxPosition(newbox, leftpos, toppos)
  735.     call ppm_SetBoxScale(newbox, (scaleX *scale1* Yscale), (scaleY * abs(scale1)) )
  736.     toppos = toppos+widthY
  737.     end
  738.  
  739.  
  740. /* Place bottom units  */
  741.  
  742. call ppm_ShowStatus("Placing Bottom Units")
  743. leftpos = mainXpos+breadth+mainwidth
  744. toppos = mainYpos+word(mainsize, 2)
  745.  
  746. do j=1 to widthcount
  747.     newbox = ppm_CloneBox(sidebox, 0, 0)
  748.     call ppm_AddToGroup(newbox)
  749.     call ppm_SetBoxAngle(newbox, 180)
  750.     call ppm_SetBoxSize(newbox, widthX, breadth)
  751.     call ppm_SetBoxPosition(newbox, leftpos, toppos)
  752.     call ppm_SetBoxScale(newbox, (scaleX *scale1* Xscale), (scaleY * abs(scale1)) )
  753.     leftpos = leftpos-widthX
  754.     end
  755.  
  756. /* Place left side units */
  757. call ppm_ShowStatus("Placing Left Side Units")
  758. toppos = mainYpos+breadth+mainheight
  759. leftpos = mainXpos
  760.  
  761. do j=1 to heightcount
  762.     newbox = ppm_CloneBox(sidebox, 0, 0)
  763.     call ppm_AddToGroup(newbox)
  764.     call ppm_SetBoxAngle(newbox, 90)
  765.     call ppm_SetBoxSize(newbox, widthY, breadth)
  766.     call ppm_SetBoxPosition(newbox, leftpos, toppos)
  767.     call ppm_SetBoxScale(newbox, (scaleX *scale1* Yscale), (scaleY * abs(scale1)) )
  768.     toppos = toppos-widthY
  769.     end 
  770.  
  771. /* Merge all the units into one box  */
  772. borderbox = ppm_MergeGroup()
  773. call ppm_SetBoxAngle(borderbox,mainangle)
  774.  
  775. /* resize box slightly so that thick lines are not cropped */
  776. bsize = ppm_GetBoxSize(borderbox)
  777. bwidth = word(bsize,1)
  778. bheight = word(bsize,2)
  779. call ppm_SetBoxSize(borderbox,bwidth+(maxwt*2),bheight+(maxwt*2))
  780. call ppm_SetBoxPosition(borderbox,mainXpos-maxwt,mainYpos-maxwt)
  781. call ppm_SetBoxOffset(borderbox,maxwt,maxwt)
  782.  
  783. /* Delete the pattern boxes  */
  784.  
  785.     gone = ppm_DeleteBox(cornerbox)
  786.     gone = ppm_DeleteBox(sidebox)   
  787.  
  788. /* Set an arbitrary margin in main box  */
  789. margin = breadth
  790. boxtype = upper(word(ppm_GetBoxInfo(mainbox),1))
  791. if boxtype = "TEXT" then margin = breadth*2
  792. call ppm_SetBoxMargins(mainbox, margin, margin, margin, margin)
  793. call ppm_BoxToFront(borderbox)
  794.  
  795. call exit_msg()
  796.  
  797. end
  798.  
  799. error:
  800. syntax:
  801.     do
  802.     exit_msg("Genie failed due to error: "errortext(rc))
  803.     end
  804.  
  805. break_d:
  806. break_e:
  807. break_c:
  808. halt:
  809. call exit_msg("Aborted by User")
  810.  
  811. exit_msg:
  812.     do
  813.     parse arg message
  814.     if message ~= "" then
  815.     call ppm_Inform(1, message,"Resume")
  816.     call ppm_ClearStatus()
  817.     call ppm_SetUnits(CurrentUnits)
  818.     call ppm_AutoUpdate(1)
  819.     exit
  820.     end
  821.  
  822.